You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecated scopes were excluded from category toggle and Select All, causing the selected scope count badge to disagree with actual state. Badge count now reads from activeScopes directly instead of effectiveScopes to avoid reactivity lag. Deprecated scopes still display the Deprecated badge for visibility.
This PR fixes two related issues in the API key scopes selector: deprecated scopes were excluded from category-level batch toggling, and the per-category badge count used effectiveScopes (which applies a legacy-to-newer scope remapping) instead of activeScopes directly, causing the badge to lag or miscount.
Category toggle fix: removes the !s.deprecated guard from onCategoryChange so deprecated scopes participate in batch select/deselect alongside non-deprecated ones.
Badge count fix: switches scopesLength to read activeScopes[n.scope] directly instead of effectiveScopes.includes(n.scope), eliminating the reactivity lag caused by the intermediate getEffectiveScopes transformation.
Confidence Score: 3/5
The badge count fix is correct, but the header checkbox state computed by categoryState still runs through getEffectiveScopes, which can diverge from the new badge count and cause the checkbox to show indeterminate when everything is actually selected.
The categoryState function was not updated alongside the badge-count change. It converts scope IDs with getEffectiveScopes before checking membership, so deprecated scopes whose IDs remap (e.g. collections.read to tables.read) are not found in scopeSet. Now that category toggles include deprecated scopes, a fully-selected category containing such a scope will show indeterminate on the header checkbox. Clicking that checkbox to fix it calls onCategoryChange and silently deselects the whole category.
The single changed file scopes.svelte needs attention, specifically the categoryState function at lines 169–183.
Removes !s.deprecated guard from category toggle and switches badge count from effectiveScopes to activeScopes; fixes badge discrepancy but leaves categoryState using getEffectiveScopes mapping, which can cause the header checkbox to show indeterminate when all scopes (including deprecated) are selected.
Comments Outside Diff (1)
src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte, line 169-183 (link)
categoryState mismatch after deprecated scope inclusion
categoryState builds scopeSet via getEffectiveScopes(scopes), which remaps legacy IDs (e.g. collections.read → tables.read). After this PR allows batch-toggling deprecated scopes, a user who selects all scopes in a category — including a deprecated one like collections.read — will produce scopes = [..., 'collections.read']. getEffectiveScopes converts that to tables.read, so scopeSet never contains 'collections.read'. When categoryState iterates scopesByCategory and checks scopeSet.has('collections.read'), it returns false, causing activeInCategory.length < scopesByCategory.length and an 'indeterminate' result instead of true. The header checkbox then shows indeterminate; if the user clicks it to "fix" it, onCategoryChange fires and unintentionally deselects everything. The badge count (now reading activeScopes directly) and the header checkbox state will diverge on any category containing deprecated compat-pair scopes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deprecated scopes were excluded from category toggle and Select All, causing the selected scope count badge to disagree with actual state. Badge count now reads from activeScopes directly instead of effectiveScopes to avoid reactivity lag. Deprecated scopes still display the Deprecated badge for visibility.